import org.junit.Test;

import utl.mofen.jsonStreamHandler.HandlerFactory;
import utl.mofen.jsonStreamHandler.IJSonStreamHandler;
import utl.mofen.objects.JSonStream;
import utl.mofen.objects.KeyStream;
import utl.mofen.objects.KeyStreamCoder;
import utl.mofen.utils.GsonUtil;
import utl.mofen.utils.ResLoader;

import com.google.gson.JsonObject;


public class SampleHandlerTester {
	@Test
	public void login() throws Exception
	{
		String s = ResLoader.getString("/script/Sample_Handler_userCentre.txt");
		System.out.println(s);
		JSonStream jsonStream = new JSonStream();
		jsonStream.initialize();
		JsonObject jsonObject = GsonUtil.parseObject(s);
		jsonStream.setJsonObject(jsonObject);		
		HandlerFactory.checkInitialize(null);
		
		IJSonStreamHandler handler = HandlerFactory.createHandler(jsonStream);
		handler.setJSonStream(jsonStream);
		handler.doAction();
		
		System.out.println(GsonUtil.json2String(jsonStream.getJSonObject()));
	}
	
	@Test
	public void loginTimes() throws Exception
	{
		login();
		login();
	}
}
